//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
#ifndef DISPLAY_PROPERTIES_HPP
#define DISPLAY_PROPERTIES_HPP

#include "stdafx.h"
#ifdef UNDER_CE
	#include "commonresource.h"
#else
	#include "vc_resource.h"
#endif
#include "GenericPropClasses.hpp"
#include "Display_OEM.h"

// String Constants for the Registry Entries
#define LOCAL_COLOR_KEY TEXT("\\SYSTEM\\Colors")
#define COLOR_TABLE_NAME1 TEXT("ColorTable0Name")
#define COLOR_TABLE_NAME2 TEXT("ColorTable1Name")
#define LOCAL_COLOR_CONFIG_KEY TEXT("\\Software\\Microsoft\\WBT\\Monitor")
#define COLOR_VALUE_NAME TEXT("Color")
#define DISPLAY_VALUE_NAME TEXT("Desktop Area Frequency")
#define RESOLUTION_CHOICES_NAME TEXT("\\Software\\Microsoft\\WBT\\Monitor\\Resolution")
// Maximum Color Table Table entries
#define MAX_COLOR_KEYS  15
// Maximum Display and Refresh Area Keys
//AAS 
//#define MAX_DISPLAY_KEYS 10
#define MAX_DISPLAY_KEYS 30
// Color Combo Text Length
#define COLORCOMBO_LEN 50
//Display Combo Text Length
#define DISPLAYCOMBO_LEN 50
const int Color8 = 0;
const int Color16 = 1;

class CDisplayPropPage : public CTerminalPropPage
{
public:
	CDisplayPropPage (CTerminalPropSheet *pOwner = NULL);
	~CDisplayPropPage();

	virtual BOOL WriteRegistrySettings();
	virtual BOOL ReadRegistrySettings();
	virtual BOOL StoreData();
	virtual BOOL Validate();
	virtual LRESULT OnSetActive (int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

	LPCTSTR GetId()
	{ return TEXT("Display"); }

	BEGIN_MSG_MAP(CDisplayPropPage)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_HANDLER (IDC_ENABLE_SCR_SVR_CHK, BN_CLICKED, OnScrCheck)
		COMMAND_HANDLER (IDC_DISPLAYBBAR_CHK, BN_CLICKED, OnBbarCheck)
		COMMAND_HANDLER (IDC_TEST_BTN, BN_CLICKED, OnDisplayTest)
		COMMAND_HANDLER (IDC_COLOR_COMBO, CBN_SELCHANGE, OnColorChoicesChange)
		MESSAGE_HANDLER(WM_COMMAND, OnCommandMsg)

		CHAIN_MSG_MAP (CTerminalPropPage)
	END_MSG_MAP()

	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnCommandMsg(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnScrCheck (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnBbarCheck (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnDisplayChoicesChange ();
	LRESULT OnDisplayTest (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnColorChoicesChange (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);

	void UpdateScreenSaver();	// Function to update the Screen Saver Attributes.
	BOOL UpdateColorChoices();	// Function to update Color schemes
	BOOL SetColorInfo();
	BOOL UpdateDisplayChoices();
	BOOL SetDisplayInfo();
	void UpdateBitmap();
		// Function to Set Color Info in Registry

	//AAS
        void SyncDisplaySettings();
        void ResetDisplay2DefaultSetting();

	void OEMDisplayInit();
	void OEMDisplayTest();
	void OEMDisplayUpdate();
	void OEMDisplayExecute( DWORD testMode );
	Display_OEM* oemDisplay;

private:
	typedef struct _COLORINFO
	{
		DWORD colorTableValue;
		TCHAR colorTableName[MAX_PATH];
		_COLORINFO* next;
	}COLORINFO,*PCOLORINFO;
	
	PCOLORINFO headColorInfo;

	BOOL m_bTested;
	int m_curSetting;

	BOOL GetCurrentColorSetting (DWORD* curColor);
	BOOL GetCurrentDisplaySetting (TCHAR * curDisplay);
	


	BOOL m_bScrSaver;
	int m_nScrTimeout; // stored as minutes here, but stored as seconds in the registry
	int m_displayType;

	BOOL m_colorChanged; // to check whether the color selection has changed.
	BOOL m_displayChanged; // to check whether the color selection has changed.
	BOOL m_bWizard;

	TCHAR* m_displayTableName[MAX_DISPLAY_KEYS];
	
	// objects to encapsulate controls
	CWindow m_scrSaverCheck, m_scrSaverTimeout;
	CWindow m_displayChoices;
	CWindow m_test;
	CWindow m_spinctl; 
	CWindow m_colorChoices;
	CWindow m_scrWait;
	CWindow m_wndBitmap;
	
	CWindow m_wndDisplayBbar;
	BOOL    m_bDisplayBbar;


};


// cleanup dialog 
class CCleanUpDlg : public CDialogBase
{
public:
	CCleanUpDlg() : CDialogBase(CCleanUpDlg::IDD) {}
	~CCleanUpDlg() {}

	BEGIN_MSG_MAP(CCleanUpDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
	END_MSG_MAP()

	enum { IDD = IDD_CLEANUP_DLG };

	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
};


#endif //DISPLAY_PROPERTIES_HPP
